package model;

import android.util.Log;

import base.BaseModel;
import base.BaseObserver;
import base.ResultCallBack;
import bean.AllBean;
import bean.ResultBean;
import jiyun.com.yiyanmeng.http.HttpManager;
import jiyun.com.yiyanmeng.http.MySerivce;
import utils.RxUtil;

/**
 * Created by 裘翔 on 2019/11/6.
 */

public class AllModel extends BaseModel {
    public void loadData(final ResultCallBack<AllBean> callBack, int start, int end) {
        MySerivce mySerivce = HttpManager.getInstance().getSerivce();
        mySerivce.getAll(start,end)
                .compose(RxUtil.<ResultBean<AllBean>>changeThread())
                .compose(RxUtil.<AllBean>changeResult())
                .subscribe(new BaseObserver<AllBean>() {
                    @Override
                    public void onSuccess(AllBean allBean) {
                        callBack.onSuccess(allBean);
                        Log.i("tag","onSuccess："+allBean.toString());
                    }

                    @Override
                    public void onFail(String error) {
                        callBack.onFail(error);
                        Log.i("tag","error："+error);
                    }
                });
    }
}
